interface DateInfo {
  date: string;
  info: string;
}

export function addMissingDates(data: DateInfo[]): void {
  const startDate = new Date(data[0].date);
  const endDate = new Date(data[data.length - 1].date);

  let currentDate = new Date(startDate);

  while (currentDate <= endDate) {
      const dateString = currentDate.toISOString().split('T')[0];
      const existingData = data.find(item => item.date === dateString);
      
      if (!existingData) {
          data.push({ date: dateString, info: "补签" });
      }
      
      currentDate.setDate(currentDate.getDate() + 1);
  }

  // 对数组进行排序，确保日期顺序是正确的
  data.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
}

// 示例用法
// const originalData: DateInfo[] = [
//   {"date": "2024-03-01", "info": "已打卡"},
//   {"date": "2024-03-05", "info": "已打卡"},
//   {"date": "2024-03-20", "info": "已打卡"},
//   {"date": "2024-03-22", "info": "已打卡"}
// ];

// addMissingDates(originalData);
// console.log(originalData);
